/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-29 22:22:49
 * @LastEditTime: 2021-08-29 22:23:57
 * @LastEditors: changqing
 * @Usage: 
 */
var { race,of,timer, interval } = require('rxjs');
var { map,take} = require('rxjs/operators');

 const sourceA = interval(1000).pipe(map((data) => `A${++data}`));
 const sourceB = interval(2000).pipe(map((data) => `B${++data}`));
 const sourceC = interval(3000).pipe(map((data) => `C${++data}`));

race([sourceA, sourceB, sourceC]).subscribe((data) =>
console.log(`race 示例: ${data}`)
);
  // race 示例: A1
  // race 示例: A2
  // race 示例: A3
  // race 示例: A4
  // race 示例: A5
  // race 示例: A6
  // race 示例: A7
  // race 示例: A8
  // race 示例: A9
  // race 示例: A10
  // 因为sourceA已经先到了,其他的Observables就退订不处理